using System;
using BitMango;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class ConsentTargetingAds : MonoBehaviour
{
	public void Initialize(BMConsentSetting setting)
	{
		this.advertisingPartnersURL = setting.advertisingPartnersURL;
		this.privacyPolicyURL = setting.privacyPolicyURL;
		this.termsOfServiceLabel.text = string.Format(this.termsOfServiceLabel.text, setting.companyDisplayName);
	}

	public void Show()
	{
		if (EventSystem.current == null)
		{
			UnityEngine.Object.Instantiate<EventSystem>(Resources.Load<EventSystem>("EventSystem"));
		}
		this.targetingAdsToggle.isOn = Platform.IsTargetingAdsAgreed;
		base.gameObject.SetActive(true);
	}

	public void Hide()
	{
		base.gameObject.SetActive(false);
	}

	public void OnClickAdvertisingNetworksAndTheirPartnersLink()
	{
		Application.OpenURL(this.advertisingPartnersURL);
	}

	public void OnClickHereLink()
	{
		Application.OpenURL(this.privacyPolicyURL);
	}

	public void OnClickTargetingAdsToggle(Toggle toggle)
	{
		Platform.IsTargetingAdsAgreed = toggle.isOn;
	}

	public void OnClickSaveButton()
	{
		if (this.OnDidClickSave != null)
		{
			this.OnDidClickSave();
		}
	}

	public Action OnDidClickSave;

	[SerializeField]
	private Toggle targetingAdsToggle;

	[SerializeField]
	private Text termsOfServiceLabel;

	private string advertisingPartnersURL;

	private string privacyPolicyURL;
}
